package com.asp.alumnisystem.adapter;

import android.os.Bundle;
import android.view.View;

import com.asp.alumnisystem.R;
import com.asp.alumnisystem.base.IRefreshView;
import com.asp.alumnisystem.model.ForumModel;
import com.asp.alumnisystem.model.NoticeModel;
import com.asp.alumnisystem.ui.NoticeInfoActivity;
import com.asp.alumnisystem.utils.TimeUtils;
import com.asp.alumnisystem.utils.UiUtils;

/**
 * 首页公告列表中显示公告信息的adapter
 */
public class NoticeListAdapter extends AspBaseAdapter<NoticeModel> {

    public NoticeListAdapter(IRefreshView refreshView) {
        super(refreshView);
    }

    @Override
    protected int getItemLayoutId(int type) {
        return R.layout.notice_list_item_layout;
    }

    @Override
    protected void bindView(RViewHolder viewHolder, int position, final NoticeModel model) {
        viewHolder.setText(R.id.notice_title, model.getNoticeTitle());
        viewHolder.setText(R.id.notice_content, model.getNoticeContent());
        viewHolder.setText(R.id.notice_temp, TimeUtils.longTime2String(model.getCreateTime(), TimeUtils.timePattern2));

        viewHolder.setItemOnClick(viewHolder.itemView, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putSerializable("model", model);
                UiUtils.jumpToPage(v.getContext(), NoticeInfoActivity.class, bundle);
            }
        });
    }
}
